#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
#include<sys/stat.h>
#include<fcntl.h>

int main(){
	int aflag = access("fifo.bt",F_OK);
	if(aflag!=0){
		int ret = mkfifo("fifo.bt",0777);
		if(ret<0){
			perror("make fifo error");
			return -1;
		}


	}

	int fd = open("fifo.bt",O_RDWR);
	if(fd<0){
		perror("open error");
		return -1;
	}
	sleep(10);
	int fid = open("../test.txt",O_RDONLY);
	if(fid<0){
		perror("输入文件读取错误");
		return -1;
	}
	size_t ret;
	char buf[64];
	memset(buf,0x00,sizeof(buf));
	while((ret=read(fid,buf,sizeof(buf)))){
				write(fd,buf,ret);				
				}

	return 0;
}
